<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .father {
        width: 200px;
        height: 200px;
        background-color: green;
      }
      .son {
        width: 100px;
        height: 100px;
        background-color: blue;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <!-- stop修饰符用于阻止冒泡 -->
      <div class="father" @click="fatherClick">
        <div class="son" v-on:click.stop="sonClick"></div>
      </div>

      <!-- prevent修饰符用于阻止默认行为 -->
      <form action="" @submit.prevent="onSubmit">
        <!-- 按键修饰符，vue3将按键码功能删除了 -->
        <input type="text" @keydown.enter="onkeydown" />
        <input type="submit" />
      </form>

      <button @click.ctrl.exact="onClick">A</button>
    </div>

    <script src="./Vue3.js"></script>
    <script>
      const { createApp } = Vue;

      createApp({
        data() {
          return {};
        },
        methods: {
          sonClick() {
            // e.stopPropagation();
            console.log("son click");
          },
          fatherClick() {
            console.log("father click");
          },
          onSubmit() {
            console.log("submit");
          },
          onkeydown(e) {
            // if (e.keyCode === 13) {
            // if (e.key === "Enter") {
            console.log(e.target.value);
            // }
          },
          onClick() {
            console.log(123);
          },
        },
      }).mount("#app");
    </script>
  </body>
</html>
